<template>
  <div>
    <f-table ref="table" size="small" rowKey="processId" :columns="columns" :multiple="false" :operator="operator" :params="queryParam" :api="api.tasktodo.listDone" handler="refundTaskTodoListHandler">
        <span slot="amountType" slot-scope="text, record, index">
            <a-tag color="#2db7f5" v-if="text=='Refund'">厂家返款</a-tag>
            <a-tag color="#f50" v-if="text=='SbReturn'">退垫付款</a-tag>
        </span>
      <span slot="action" slot-scope="text, record">
          <template>
              <a href="javascript:;" @click="$refs['refund'].showDrawer(record,'form2')" v-if="record.amountType=='Refund'">查看</a>
              <a href="javascript:;" @click="$refs['sbreturn'].showDrawer(record,'form2')" v-if="record.amountType=='SbReturn'">查看</a>
              <a-divider type="vertical"/>
              <a href="javascript:;" @click="processImg(record)">审批进度</a>
          </template>
        </span>
    </f-table>
    <process-image ref="processImg" v-if="processImageVisible" :visible.sync="processImageVisible" :processInstanceId="processInstanceId"></process-image>
    <order-supplier-bond-drawer ref="osbd"></order-supplier-bond-drawer>
    <refund-drawer ref="refund"></refund-drawer>
    <sbreturn-drawer ref="sbreturn" @success="onLoad"></sbreturn-drawer>
  </div>
</template>
<script>

  import api from './../js/api'
  import ProcessImage from '../../process/process_image'
  import OrderSupplierBondDrawer from '../../../business/order/supplierbond/supplierbond_drawer'
  import RefundDrawer from '../../../business/order/refund/refund_drawer'
  import SbreturnDrawer from '../../../business/order/sbreturn/sbreturn_drawer'

  export default {
    name: 'TableList',
    components: {
      OrderSupplierBondDrawer,
      ProcessImage,
      RefundDrawer,
      SbreturnDrawer
    },
    data() {
      let me = this
      //操作按钮
      let operator = []

      return {
        api: Object.assign(api, this.api),
        //列表初始化查询参数
        queryParam: {},
        processInstanceId: '',
        processImageVisible: false,
        // 表头
        columns: [
          {
            title: '#',
            width: '60',
            align: 'center',
            customRender: (text, record, index) => index + 1
          },
          {
            title: '单号',
            align: 'center',
            dataIndex: 'paymentNo'
          },

          {
            title: '单据类型',
            align: 'center',
            dataIndex: 'amountType',
            scopedSlots: { customRender: 'amountType' }
          },
          {
            title: '供货方',
            align: 'center',
            dataIndex: 'supplierName'
          },
          {
            title: '返款金额',
            align: 'center',
            dataIndex: 'amount'
          },

          {
            title: '返款日期',
            align: 'center',
            dataIndex: 'amountDate'
          },
          {
            title: '开票单位',
            align: 'center',
            dataIndex: 'unitName'
          },
          {
            title: '开票金额',
            align: 'center',
            dataIndex: 'invoiceAmount'
          },
          {
            title: '开票日期',
            align: 'center',
            dataIndex: 'createTime'
          },
          {
            title: '审批人',
            align: 'center',
            dataIndex: 'assignee'
          },
          {
            title: '审批状态',
            align: 'center',
            dataIndex: 'taskName'
          },
          {
            title: '制单人',
            align: 'center',
            dataIndex: 'nickName'
          },
          {
            title: '创建日期',
            align: 'center',
            dataIndex: 'createTime'
          },
          {
            title: '操作',
            align: 'center',
            scopedSlots: { customRender: 'action' }
          }
        ],
        operator: operator
      }
    },
    created() {
    },
    methods: {
      onLoad() {
        this.$refs.table.refresh()
      },
      /**
       * 查询事件
       * @param searchParams
       */
      searchTable(searchParams) {
        this.queryParam = Object.assign(this.queryParam, searchParams)
        this.$refs.table.refresh(true, searchParams)
      },
      processImg(task) {
        this.processInstanceId = task.processInstanceId
        this.processImageVisible = true
      },
    }
  }
</script>
